package com.leyou.trade.utils;

import org.springframework.stereotype.Component;

/**
 * <h3>leyou-project</h3>
 * <p></p>
 *
 * @author : hhw
 * @date : 2020-06-08 14:58
 **/
@Component
public class UserHolder {
    public static final ThreadLocal<Long> TL = new ThreadLocal<>();
    public static void setUser(Long userId) {
        TL.set(userId);
    }
    public static Long getUser() {
        Long userId = TL.get();
        if (userId == null) {
            return 0L;
        }
        return userId;
    }
    public static void removeUser(){
        if (TL.get() != null) TL.remove();
    }



}
